package io.github.javpower.knowledgerag.controller;

import io.github.javpower.knowledgerag.req.QuestionReq;
import io.github.javpower.knowledgerag.service.QnAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/qna")
public class QnAController {
    private final QnAService qnaService;

    @Autowired
    public QnAController(QnAService qnaService) {
        this.qnaService = qnaService;
    }

    @PostMapping("/ask")
    public String askQuestion(@RequestBody QuestionReq req) {
        return qnaService.generateAnswer(req);
    }


    @PostMapping("/vectorQuery")
    public String vectorQuery(String queryString)  {
        return qnaService.vectorQuery(queryString);
    }


    @PostMapping("/functionCall")
    public String functionCall(String queryString)  {
        return qnaService.functionCall(queryString);
    }

}